<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="module" src="index.js"></script>

    <style>
        /* 直到影子dom的dom结构被添加之后才会出现，非常有用 */
        :not(:defined) {
            display: block;
            opacity: 0;
            transition: all .3s ease;
        }

        * {
            -webkit-font-smoothing: antialiased;
            -webkit-overflow-scrolling: touch;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            -webkit-text-size-adjust: none;
            -webkit-touch-callout: none;
            box-sizing: border-box;
        }

        ::-webkit-scrollbar {
            /* 对应纵向滚动条的宽度 */
            width: 5px;
            /* 对应横向滚动条的宽度 */
            height: 10px;
            background-color: #dbeffd;
        }
    </style>

</head>

<body>
    你好
    <my-div option="测试" name="测试">
        <div slot="container" id="test">
            hello
        </div>

        <div slot="container" id="test" class="active">
            tab1
        </div>

        <div slot="container" id="test" class="active">
            tab2
        </div>
        <div slot="container" id="test" class="active">
            tab3
        </div>

    </my-div>

    <script>

        

        let init = document.createElement("my-div")
        // 
        setTimeout(() => {
            // console.log(init.shadowRoot.querySelectorAll("div"))

            console.log(document.querySelector(`my-div[option="你好"]`).getAttribute("name"))
            document.querySelector(`my-div[option="你好"]`).setAttribute("name","setnama")
        
        }, 4000)

        document.body.appendChild(init)
        // document.body.remove(init)
        // customElements.
        customElements.whenDefined('my-div').then(() => {
            console.log("开始define")
            // document.querySelector("my-div").setAttribute("", "你好")
            document.querySelector("my-div").setAttribute("option", "你好")
        });
        // setTimeout(() => {
        //     console.log(document.querySelector("my-div").shadowRoot.querySelector(`slot[name="container"]`).assignedElements({ flatten: true }))
        // }, 3000);
    </script>
</body>

</html>